package com.odobenus.sample;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.odobenus.client.loader.RefreshPropertySource;
 
@Component
public class RefreshScheduler {
 
    @Autowired
    private ConfigurableEnvironment environment;
 
    @Autowired
    private RefreshPropertySource  refreshPropertySource;

    //@Scheduled(cron = "0/5 * * * * ? ") // 间隔5秒执行
    public void scheduling() {
    	refreshPropertySource.refresh(environment);
        System.out.println(environment.getProperty("spring.datasource.url"));
    }
 
}